package edu.npu.GraphIndex;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.WritableComparable;

//表示边
public class EdgeWritable implements WritableComparable<EdgeWritable>{
	LongWritable src, dist;
	public EdgeWritable() {
		src = new LongWritable();
		dist = new LongWritable();
	}
	public EdgeWritable(LongWritable src, LongWritable dist) {
		this();
		src.set(src.get());
		dist.set(dist.get());
	}
	@Override
	public void readFields(DataInput in) throws IOException {
		src.readFields(in);
		dist.readFields(in);
	}
	@Override
	public void write(DataOutput out) throws IOException {
		src.write(out);
		dist.write(out);
	}
	@Override
	public int compareTo(EdgeWritable other) {
		if(src.compareTo(other.src) > 0) {
			return 1;
		} else {
			if(dist.compareTo(other.dist) > 0) {
				return 1;
			}
		}
		return -1;
	}
}
